#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
	int x = 0, y = 0, z = 0;
	scanf("%d%d", &x, &y)!=EOF;
	z = x % y;
	while (z != 0)
	{
		x = y;
		y = z;
		z = x % y;
	}
	printf("%d\n", y);
	return 0;
}